axios.defaults.baseURL = 'http://big-event-vue-api-t.itheima.net'

// axios请求拦截，所有的请求在发送之前，都会经过拦截器，主要是做一些请求的检查
axios.interceptors.request.use(config => {
  // Do something before request is sent
  let token = localStorage.getItem('token') || ''
  if(token) {
    // Authorization不能乱写，前台共同约定的
    config.headers.Authorization = token
  }
  return config;
}, error => {
  // Do something with request error
  return Promise.reject(error);
});